//
//  ZZOpenView.m
//  ZZBlue
//
//  Created by stonesMonkey on 2017/9/21.
//  Copyright © 2017年 stonesMonkey. All rights reserved.
//

#import "ZZOpenView.h"
#import "UIImage+ZUtilities.h"

@interface ZZOpenView()

@property (weak, nonatomic) IBOutlet UIButton *openBtn;

@property (weak, nonatomic) IBOutlet UIButton *offBtn;


@end

@implementation ZZOpenView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.layer.cornerRadius = 16;
    self.layer.masksToBounds = YES;
    
    self.openBtn.layer.cornerRadius = 8;
    self.openBtn.layer.masksToBounds = YES;
    
    self.offBtn.layer.cornerRadius = 8;
    self.offBtn.layer.masksToBounds = YES;
    
    [self.openBtn setBackgroundImage:[UIImage zImageWithColor:[UIColor redColor] size:CGSizeMake(14, 14) andRadius:14 ] forState:UIControlStateSelected];
    
    [self.offBtn setBackgroundImage:[UIImage zImageWithColor:[UIColor redColor] size:CGSizeMake(14, 14) andRadius:14 ] forState:UIControlStateSelected];

    self.openBtn.selected = YES;
}

- (IBAction)openBtnClick:(UIButton *)sender {
    
    if (sender.selected == YES) {
        return;
    } else {
        
        sender.selected = YES;
         self.offBtn.selected = NO;
        if (self.onClick) {
            
            self.onClick();
        }
    }
}

- (IBAction)offBtnClick:(UIButton *)sender {
    
    if (sender.selected == YES) {
        return;
    } else {
        
        sender.selected = YES;
        self.openBtn.selected = NO;
        if (self.offClick) {
            
            self.offClick();
        }
    }
}


@end
